<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of confMatrix</title>
  <meta name="keywords" content="confMatrix">
  <meta name="description" content="Generates a confusion matrix according to true and predicted data labels.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../m2html.css">
</head>
<body>
<a name="_top"></a>
<!-- menu.html classify -->
<h1>confMatrix
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>Generates a confusion matrix according to true and predicted data labels.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="box"><strong>function CM = confMatrix( IDXtrue, IDXpred, ntypes ) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../up.png"></a></h2>
<div class="fragment"><pre class="comment"> Generates a confusion matrix according to true and predicted data labels.

 CM(i,j) denotes the number of elements of class i that were given label
 j.  In other words, each row i contains the predictions for elements whos
 actual class was i.  If IDXpred is perfect, then CM is a diagonal matrix
 with CM(i,i) equal to the number of instances of class i.

 To normalize CM to [0,1], divide each row by sum of that row:
  CMnorm = CM ./ repmat( sum(CM,2), [1 size(CM,2)] );

 USAGE
  CM = confMatrix( IDXtrue, IDXpred, ntypes )

 INPUTS
  IDXtrue     - [nx1] array of true labels [int values in 1-ntypes]
  IDXpred     - [nx1] array of predicted labels [int values in 1-ntypes]
  ntypes      - maximum number of types (should be &gt; max(IDX))

 OUTPUTS
  CM          - ntypes x ntypes confusion array with integer values

 EXAMPLE
  IDXtrue = [ones(1,25) ones(1,25)*2];
  IDXpred = [ones(1,10) randint2(1,30,[1 2]) ones(1,10)*2];
  CM = confMatrix( IDXtrue, IDXpred, 2 )
  confMatrixShow( CM, {'class-A','class-B'}, {'FontSize',20} )

 See also <a href="confMatrixShow.html" class="code" title="function confMatrixShow( CM, types, pvPairs, nDigits, showCnts )">CONFMATRIXSHOW</a>

 Piotr's Computer Vision Matlab Toolbox      Version 2.12
 Copyright 2014 Piotr Dollar.  [pdollar-at-gmail.com]
 Licensed under the Simplified BSD License [see external/bsd.txt]</pre></div>





<!-- Start of Google Analytics Code -->
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-4884268-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<!-- end of Google Analytics Code -->

<hr><address>Generated by <strong><a href="http://www.artefact.tk/software/matlab/m2html/" target="_parent">m2html</a></strong> &copy; 2003</address>
</body>
</html>
